<template>
	<view class="centerSubsidy">
		<view class="cSHead">
			<view class="cSHeadBox" @click="cli_head(item)" v-for="(item, index) of  list_head" :key="index">
				<view class="cSHeadText" :class="[index_head == index? 'cSHeadTextTwo': '']">
					{{item}}
				</view>
				<view class="cSHeadBoxBtm" :class="[index_head == index? 'cSHeadBoxBtmTwo': '']">

				</view>
			</view>
		</view>
		<view class="cSMain" v-if="list && list.length > 0">
			<view class="cSMainLi" v-for="(item, index) of list" :key="index">
				<view class="" @click="cli_goNext(item, index)">
				<view class="cSMainLiHead">
					申请时间：{{item.createTime}}
				</view>
				<view class="cSMainLiBox" style="margin-top: 26rpx;">
					<view class="cSMainLiBoxL">
						故障配件名称：
					</view>
					<view class="cSMainLiBoxR">
						{{item.attributeName}}
					</view>
				</view>
				<view class="cSMainLiBox">
					<view class="cSMainLiBoxL">
						补助金额：
					</view>
					<view class="cSMainLiBoxR">
						{{item.payPrice}}元
					</view>
				</view>
				<view class="cSMainLiBox">
					<view class="cSMainLiBoxL">
						鉴定市县：
					</view>
					<view class="cSMainLiBoxR" v-if="item.partsStorePerson">
						<text>{{item.partsStorePerson}}</text>
						<text style="margin-left: 32rpx;">{{item.partsStorePhone}}</text>
					</view>
				</view>
				</view>
				<view class="cSMainLiBtn font_blod" v-if="index_head == 0">
					<view class="cSMainLiBtnL" @click="cli_playPhone(item.partsStorePhone)">
						<image class="cSMainLiBtnLImg" src="https://www.zzzsyh.com/applets/agent/agent/phone.png" mode=""></image>
						<text class="cSMainLiBtnLTxt">拨打电话</text>
					</view>
					<view class="cSMainLiBtnR" @click="cli_goNext(item, index)">
						去处理
					</view>
				</view>
				<view class="cSMainLiImg" v-if="index_head == 1">
					<image class="cSMainLiImgImg" v-if="item.applyStatus == 3 || item.applyStatus > 4" src="https://www.zzzsyh.com/applets/agent/agent/pass_bg.png" mode=""></image>
					<image class="cSMainLiImgImg" v-if="item.applyStatus == 4" src="https://www.zzzsyh.com/applets/agent/agent/bohui_bg.png" mode=""></image>
				</view>
			</view>
		</view>
		<view v-else class="cSMain" style="margin-top: 40%;">
			<view class="yPopNone">
				<image class="yPopNoneImg" src="https://www.zzzsyh.com/applets/agent/factory/23.png" mode=""></image>
				<view class="yPopNoneTxt">
					暂无审核
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import allapi from '../api/index.js'
	export default {
		data() {
			return {
				agentId: uni.getStorageSync('agentId'),
				list_head: ['待处理', '已处理'],
				list: [],
				index_head: 0,
				pageNum: 1,
				isMore: true
			}
		},
		computed: {
			status() {
				let index = this.index_head
				if (index == 0) {
					return 1
				} else if (index == 1) {
					return 2
				}
			}
		},
		onShow() {
			this.pageInit()
		},
		mounted() {
			// this.getQrCodeApplyListByAgentId()
		},
		onPullDownRefresh() {
			this.pageInit()
		},
		onReachBottom() {
			let isMore = this.isMore
			if (isMore) {
				this.pageNum += 1
				this.getQrCodeApplyListByAgentId()
			} else {

			}
		},
		methods: {
			// 点击头部切换
			cli_head(val) {
				if (val == '待处理') {
					this.index_head = 0
					this.pageInit()
				} else {
					this.index_head = 1
					this.pageInit()
				}
			},
			// 点击拨打电话
			cli_playPhone(val) {
				if (val) {
					uni.makePhoneCall({
						phoneNumber: val //仅为示例
					});
				} else {
					uni.showToast({
						title: '暂无电话',
						icon: 'none'
					})
				}

			},
			// 点击跳转详情
			cli_goNext(item, index) {
				uni.navigateTo({
					url: '/pages/centerSubsidyDetails/centerSubsidyDetails?id=' + item.id
				})
			},
			// 初始化
			pageInit() {
				this.pageNum = 1
				this.isMore = true
				this.list = []
				this.getQrCodeApplyListByAgentId()
			},
			// 获取列表
			getQrCodeApplyListByAgentId() {
				console.log(1);
				uni.request({
					url: allapi.getQrCodeApplyListByAgentId,
					data: {
						agentId: this.agentId,
						pageNum: this.pageNum,
						pageSize: 10,
						status: this.status
					},
					success: (res) => {
						console.log('获取列表', res);
						let dat = res.data.data
						uni.stopPullDownRefresh()
						if (dat && dat.length > 0) {
							this.list = this.list.concat(dat)
							this.isMore = true
						} else {
							this.isMore = false
						}
					}
				})
			},
		}
	}
</script>

<style scoped>
	.centerSubsidy {
		/* position: absolute; */
		width: 100%;
		height: 100%;
		/* display: flex; */
		/* flex-direction: column; */
	}

	.cSHead {
		height: 88rpx;
		background: #FFFFFF;
		display: flex;
		width: 100%;
		position: fixed;
		left: 0;
		top: 0px;
		z-index: 66;
	}

	.cSHeadBox {
		flex: 1;
		display: flex;
		flex-direction: column;
		justify-content: center;
		align-items: center;
	}

	.cSHeadText {
		color: #999999;
		line-height: 80rpx;
		font-size: 28rpx;
		font-weight: 400;
	}

	.cSHeadTextTwo {
		color: #333333;
	}

	.cSHeadBoxBtm {
		width: 96rpx;
		height: 8rpx;
		background: #FFFFFF;
		border-radius: 4rpx;
	}

	.cSHeadBoxBtmTwo {
		background: linear-gradient(90deg, #2ACE52 0%, #1DC248 100%);
	}

	.cSMain {
		flex: 1;
		overflow: auto;
		margin-top: 88rpx;
	}

	.cSMainLi {
		margin: 24rpx;
		/* height: 398rpx; */
		background: #FFFFFF;
		border-radius: 16rpx;
		padding: 24rpx;
		position: relative;
	}

	.cSMainLiHead {
		border-bottom: 1rpx solid #EEEEEE;
		line-height: 34rpx;
		color: #999999;
		font-size: 24rpx;
		font-weight: 400;
		padding-bottom: 24rpx;
	}

	.cSMainLiBox {
		display: flex;
		align-items: center;
		margin-top: 18rpx;
	}

	.cSMainLiBoxL {
		width: 196rpx;
		font-weight: 400;
		color: #666666;
		font-size: 28rpx;
	}

	.cSMainLiBoxR {
		flex: 1;
		font-size: 32rpx;
		color: #333333;
		overflow: hidden;
		text-overflow: ellipsis;
		white-space: nowrap;
		font-weight: bold;
	}

	.cSMainLiBtn {
		display: flex;
		justify-content: space-between;
		align-items: center;
		margin: 0 64rpx;
		margin-top: 44rpx;
	}

	.cSMainLiBtnL {
		display: flex;
		align-items: center;
		width: 188rpx;
		height: 68rpx;
		border-radius: 34rpx;
		border: 2rpx solid #333333;
		font-size: 24rpx;
		color: #333333;
	}

	.cSMainLiBtnLImg {
		width: 32rpx;
		height: 32rpx;
		margin-left: 26rpx;
	}

	.cSMainLiBtnLTxt {
		margin-left: 8rpx;
	}

	.cSMainLiBtnR {
		width: 144rpx;
		height: 68rpx;
		background: linear-gradient(90deg, #2ACE52 0%, #1DC248 100%);
		border-radius: 34rpx;
		font-size: 24rpx;
		color: #FFFFFF;
		text-align: center;
		line-height: 68rpx;
	}

	.cSMainLiImg {
		position: absolute;
		right: 16rpx;
		top: 90rpx;
	}

	.cSMainLiImgImg {
		width: 152rpx;
		height: 144rpx;
	}
</style>
